import formJs from "./regexDetail.js"; //新增弹框配置项
import publicForm from "@/components/public/el-forms.vue"; //弹框form
// import CustomDialog from "@/components/HntManage/pouringOrder/WBSHuitanGangbao/index.vue";
// import CustomDialog1 from "@/components/reboundStrengthManage/reboundEntrustList/index.vue";//委托单列表页

import {
    getTestdellog, //详情
    fileUrllogId
} from "@/api/request.js";
export default {
    props: [
        "dialogVisible",
        "dialogTitle",
        "statusNum",
        "currentRow",
    ],
    data() {
        return {
            visible: "",

            loading: false,
            title: "",
            isLock: false, //保存按钮是否可编辑
            dialogHeight: null,
            formData: {},
            formObj: formJs.formObj, 
            btnShow: true,
            currentDetail: null,

            isShow: false,
            Fileurllist:[],


        };
    },
    components: {
        publicForm,
        // CustomDialog,
        // CustomDialog1
    },
    watch: {
        dialogVisible: {
            handler(newVal) {
                if (newVal) {
                    this.visible = newVal;
                }
            },
            immediate: true,
        },

        dialogTitle: {
            handler(newVal) {
                if (newVal) {
                    this.title = newVal;
                }
            },
            immediate: true,
        },

        statusNum: {
            handler(newVal) {
                if (newVal) {
                    this.edit();
                }
            },
            immediate: true,
        },

        currentRow: {
            handler(newVal) {
                if (newVal) {
                    var that = this
                    this.currentDetail = newVal;
                    if (this.statusNum != 1) {
                        setTimeout(() => {
                            that.getDetail(this.currentDetail) // currentRow

                        }, 200)
                    }
                }
            },
            immediate: true,
        },

    },
    created() {
        window.addEventListener("resize", this.getHeight);
        this.getHeight();

    }, //获取页面高度自适应：

    destroyed() {
        window.removeEventListener("resize", this.getHeight);
        this.getHeight();
    },
    mounted() {
        this.userInfo = JSON.parse(sessionStorage.getItem("monitorBack-userInfo"));



        if (this.statusNum == 7) {

            this.btnShow = false;
            this.formObj.map(item => {
                item.disabled = true;
            })
  
        }
    },
    methods: {
        refreshList() {},

        getHeight() {
            var h = document.documentElement.clientHeight; //获取页面可见高度
            this.dialogHeight = h * 0.5 + "px";
        },
        closeDialog() {
            this.$emit("close");
        },
        edit() {
            this.formData = this.$options.data.call(this).formData;
        },


        // 详情
        getDetail(row) {
            this.loading = true;
            getTestdellog({
                fId: row.fId
            }).then((res) => {
                if (res.errcode == 0) {
                    this.loading = false;
                    this.formData = res.data.testdellog;
                   this.fileUrllogId(res.data.testdellog.fId)
                

                } else {
                    this.loading = false;
                    this.$message.error(res.msg);
                }
            });
        },
        fileUrllogId(id){
            fileUrllogId({
                logId: id
            }).then((res) => {
                if (res.Result == 100) {
                 console.log(res);
                 this.Fileurllist
                 res.Data.map(item=>{
                    this.Fileurllist.push({
                        fFileName:item.FileName,
                        fFileType:item.FileSuffix,
                        fId:item.FileId,
                        url:item.FilePath,
                        isdel:item.Status
                    })
                 })
                } else {
                    this.loading = false;
                    this.$message.error(res.msg);
                }
            });
        },

        // 获取委托单列表数据
        closeDialog1() {
            this.isShow = false;
        },
     

    },
};